import { Component, OnInit } from '@angular/core';
import { CmHttp } from "http-module";
import { Observable } from "rxjs/Observable";

@Component({
  // moduleId: module.id,
  selector: 'top-list',
  templateUrl: 'top-list.component.html',
  inputs: [
    "params"
  ]
})
export class TopListComponent implements OnInit {
  params;
  list;
  constructor(private http: CmHttp) { }

  ngOnInit() {
    let {http, params} = this;
    console.debug("Top-List: ", this.params);
    Observable
      .interval(3000)
      .switchMap(() => http.get(params.dataUrl))
      .subscribe(res => this.list = res);
  }

}